import {
  Inject,
  Controller,
  Provide,
  Get,
  Query,
  Validate,
} from '@midwayjs/decorator';
import { Context } from 'egg';
// import { User } from '../../entity/user';
// import { IUserOptions } from '../../interface';
import { UserService } from '../../service/user';
import { BaseController } from '../base';

const permissionRouter = {
  path: '/permission',
  name: 'permission',
  redirect: '/permission/page',
  meta: {
    title: 'message.permission',
    icon: 'el-icon-lollipop',
    showLink: true,
    rank: 3,
  },
  children: [
    {
      path: '/permission/page',
      name: 'permissionPage',
      meta: {
        title: 'message.permissionPage',
        showLink: false,
      },
    },
    // {
    //   path: '/permission/button',
    //   name: 'permissionButton',
    //   meta: {
    //     title: 'message.permissionButton',
    //     showLink: true,
    //     authority: [],
    //   },
    // },
  ],
};

@Provide()
@Controller('/admin')
export class AuthController extends BaseController {
  @Inject()
  ctx: Context;

  @Inject()
  userService: UserService;

  @Get('/getAsyncRoutes')
  @Validate()
  async getAsyncRoutes(@Query() name: string) {
    return this.successResponse([permissionRouter]);
  }
}
